import type { BaseResponse, PageRequest } from '../http'

interface ListParams extends PageRequest {
  scheduleId?: string | number
  userId?: string | number
  worksName?: string
}

export interface SubmitWork {
  id?: string
  scheduleId?: number | string
  userId?: number
  operateType: 'SUBMIT' | 'TEMPORARY_STORAGE'
  worksName: string
  /** 是否作品组图(0，是1，否 */
  isGroupImg: string
  /** 作品简介 */
  worksIntro: string
  /** "创意理念 */
  worksOriginality: string
  /** "研究内容 */
  studyContent: string
  /** 参赛作品高清图，逗号隔 */
  worksImg: string
  /** 作品主图 */
  worksImgMain: string
  /** 承诺书附件ID */
  promise: string
  /** 作品视频附件ID */
  worksVideo: string
  /** 验证码 */
  code?: string
  isPc?: boolean

}

export interface WorksImgListItem {
  id: string
  fileName: string
  fileFormat: string
  fileUrl: string
}

export interface MemberInfoList {
  id: number
  memberTypeVal: string
  memberName: string
  sex: string
  sexVal: string
  education?: any
  profession?: any
  grade?: any
  phone: string
  unit: string
  job: string
  memberType: string
  userId: number
  scheduleId: number
  idCard: string
  key: string
}

export interface SubmitWorkInfo {
  id: string
  scheduleId: number
  scheduleTitle: string
  userId: number
  worksName: string
  isGroupImg: number
  content: string
  worksIntro: string
  worksOriginality: string
  studyContent: string
  worksImg: string
  worksImgList: WorksImgListItem[]
  worksImgMain?: any
  worksImgMainVo?: any
  promise?: any
  promiseVo?: any
  worksVideo?: any
  worksVideoVo?: WorksImgListItem[]
  delFlag: number
  worksStatus: string
  operateType?: any
  createBy: number
  createTime: string
  awardConfigId?: any
  awardName?: any
  score?: any
  finallyScore: number
  memberInfoList: MemberInfoList[]
  upvoteCount?: any
  worksEncoding: string
  lastWorkId: number
  lastWorkName: string
  nextWorkId: number
  nextWorkName: string
  isGive: boolean
}

export interface WorkListItem {
  id: string
  scheduleId: number
  worksName: string
  worksImgMain?: any
  promise: number
  worksVideo: string
  awardConfigId?: any
  worksImgMainUrl: string
  promiseUrl: string
  worksVideoList: any[]
  awardConfigName: string
  createTime: string
  previousWorksId?: any
  previousWorksName?: any
  nextWorksId?: any
  nextWorksName?: any
  worksStatus: string
  sort?: any
  worksEncoding: string
  homeShow?: any
  homeShowVal: number
}
export function getSubmitWorkList(params: ListParams) {
  return http.post<BaseResponse<{ content: WorkListItem[] }>>('/client/works/list', params)
}
export function submitWork(params: SubmitWork) {
  return http.post<BaseResponse<any>>('/client/works/submit-works', params)
}
export function deleteWorkById(ids: string) {
  return http.post<BaseResponse<any>>(`/client/works/${ids}`)
}
export function getSubmitWorkById(id: string) {
  return http.get<BaseResponse<SubmitWorkInfo>>(`/client/works/${id}`)
}

export function getWorksCode() {
  return http.get<BaseResponse<any>>('/client/code/getWorksCode')
}
